package com.hbu.housingbrokerug.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import com.hub.R;

public class SearchBaseActivity extends Activity{
	
	
	
	//Search Parameters
	public String byPriceButton="byPrice";
	public String byLocationButton="byLocation";
	public String byCompositionButton="byComposition";
	public String advancedButton="advanced";
	public String backbutton="back";

	public boolean onOptionsItemSelected(MenuItem item) {
try{
		switch (item.getItemId()) {
			case R.id.search__location1:
				startSearchActivity(byLocationButton);
				return true;
			case R.id.search_advanced1:
				startSearchActivity(advancedButton);
				return true;
			case R.id.search_back1:
				startSearchActivity(backbutton);
			   return true;   
			case R.id.search_composition1:
				startSearchActivity(byCompositionButton);
				   return true;	
			case R.id.search_price1:
				startSearchActivity(byCompositionButton);
				   return true;	
			default:
				return false;
		}
}

catch(Exception ex){
	
Log.e("ERROE", ex+"");
}
return false;
	}
	public void startSearchActivity(String actualLocation) {
		Bundle bundle=getIntent().getExtras();
		if(advancedButton.equalsIgnoreCase(actualLocation)){
		Intent intent = new Intent(this, SearchByPrice.class);
		intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
		intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
		startActivity(intent);
		}
		else if(byPriceButton.equalsIgnoreCase(actualLocation)){
			Intent intent = new Intent(this, SearchByPrice.class);
			intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
			intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
			startActivity(intent);
			}
		else if(byLocationButton.equalsIgnoreCase(actualLocation)){
			Intent intent = new Intent(this, SearchByLocation.class);
			intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
			intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
			startActivity(intent);	
			}
		
		else if(backbutton.equalsIgnoreCase(actualLocation)){
			Intent intent = new Intent(this, Search.class);
			intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
			intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
			startActivity(intent);
			}
		else if(byCompositionButton.equalsIgnoreCase(actualLocation)){
			Intent intent = new Intent(this, SearchByPrice.class);
			intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
			intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
			
			startActivity(intent);	
			}
		else if(byCompositionButton.equalsIgnoreCase(actualLocation)){
			Intent intent = new Intent(this, SearchByPrice.class);
			intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
			intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
			startActivity(intent);	
			}
			finish();
	}

}
